package com.rainbow.gwt.accounting.server.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.rainbow.gwt.accounting.client.util.DictionaryUtilService;

public class DictionaryUtilServiceImpl extends RemoteServiceServlet implements DictionaryUtilService{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public List<String> getCountries(){
		List<String> countries = new ArrayList<String>();
		BufferedReader reader = null;
		try {
			reader = new BufferedReader(new FileReader(new File(COUNTRY_TXT_FILE)));
			String country = null;
			while((country = reader.readLine()) != null){
				countries.add(country);
			}
			reader.close();
		} catch (IOException e) {
			e.printStackTrace();
		} finally{
			if(reader != null){
				try {
					reader.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		return countries;
	}
	private static final String COUNTRY_TXT_FILE = "WEB-INF/country.txt";
}
